const http = require('http');

let options = {
    hostname: "192.168.42.166",
    port: 3000,
    pathname: "/postdata",
    method: "POST",
}

let req = http.request(options , (res) => {
    // console.log(JSON.parse(res));
    console.log(123456);
    // console.log(res);
    let str = "";
    res.on("data" , (chunk) => {
        str += chunk;
    });
    res.on("end" , () => {
        console.log(JSON.parse(str));
    });
})
let userInfor = {
    "username": "zhangsan",
    "age": 20
}
req.write(JSON.stringify(userInfor));
req.end();